package com.example.authsystem.service;

import com.example.authsystem.dto.JwtResponse;
import com.example.authsystem.dto.LoginRequest;
import com.example.authsystem.dto.RegisterRequest;
import com.example.authsystem.dto.UserListResponse;
import com.example.authsystem.dto.UserProfileDto;
import com.example.authsystem.entity.User;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "用户业务服务", description = "用户认证和管理服务接口")
@Hidden
public interface UserService {

    @Operation(summary = "用户注册", description = "创建新用户账户", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "注册成功"),
            @ApiResponse(responseCode = "400", description = "用户名或邮箱已存在")
    })
    User registerUser(
            @Parameter(description = "注册请求信息", required = true, schema = @Schema(implementation = RegisterRequest.class))
            RegisterRequest registerRequest
    );

    @Operation(summary = "用户登录", description = "验证用户凭据并返回JWT令牌，支持用户名、邮箱或手机号登录", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "登录成功", content = @Content(schema = @Schema(implementation = JwtResponse.class))),
            @ApiResponse(responseCode = "400", description = "凭据错误或账户异常"),
            @ApiResponse(responseCode = "401", description = "手机号格式不正确")
    })
    JwtResponse loginUser(
            @Parameter(description = "登录凭据", required = true, schema = @Schema(implementation = LoginRequest.class))
            LoginRequest loginRequest,
            @Parameter(description = "设备标识符", required = true, schema = @Schema(type = "string"))
            String deviceId,
            @Parameter(description = "登录位置", required = true, schema = @Schema(type = "string"))
            String location
    );

    @Operation(summary = "刷新令牌", description = "使用刷新令牌获取新的访问令牌", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "刷新成功"),
            @ApiResponse(responseCode = "401", description = "刷新令牌无效或已过期"),
            @ApiResponse(responseCode = "403", description = "用户账户异常")
    })
    String refreshToken(
            @Parameter(description = "刷新令牌", required = true, schema = @Schema(type = "string"))
            String refreshToken
    );

    @Operation(summary = "获取用户列表", description = "分页查询用户列表", hidden = true)
    @ApiResponse(responseCode = "200", description = "查询成功", content = @Content(schema = @Schema(implementation = UserListResponse.class)))
    UserListResponse getUserList(int page, int size, String keyword);

    @Operation(summary = "获取用户详情", description = "根据ID获取用户信息", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "获取成功", content = @Content(schema = @Schema(implementation = UserProfileDto.class))),
            @ApiResponse(responseCode = "404", description = "用户不存在")
    })
    UserProfileDto getUserProfile(Long userId);

    @Operation(summary = "更新用户", description = "更新用户基本信息", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "更新成功", content = @Content(schema = @Schema(implementation = UserProfileDto.class))),
            @ApiResponse(responseCode = "404", description = "用户不存在"),
            @ApiResponse(responseCode = "400", description = "参数错误")
    })
    UserProfileDto updateUserProfile(Long userId, UserProfileDto userDto);

    @Operation(summary = "删除用户", description = "软删除用户", hidden = true)
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "删除成功"),
            @ApiResponse(responseCode = "404", description = "用户不存在")
    })
    void deleteUser(Long userId);
}
